﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HNG.LIB.Common;
using HNG.Portal.BLL;
using HNG.Portal.DAL;
using HNG.Portal.DAL.EntityClasses;
using HNG.Portal.DAL.FactoryClasses;
using HNG.Portal.DAL.HelperClasses;
using SD.LLBLGen.Pro.ORMSupportClasses;
using System.Web.UI.HtmlControls;
using System.Data;
using System.Text;
public partial class Controls_Products_ProductCategory : System.Web.UI.UserControl
{
    TblDanhMucSanPhamManager _TblDanhMucSanPhamManager = new TblDanhMucSanPhamManager();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            //_TblDanhMucSanPhamManager.SetCatalogToXml(Server.MapPath("~/Controls/Products/ProductCatalog.xml"));
            //LoadCatalog();
        }
    }

    //private void LoadCatalog()
    //{
    //    DataTable _dtCatalog = _TblDanhMucSanPhamManager.GetSiteMapFromXml(Server.MapPath("~/Controls/Products/ProductCatalog.xml"));
    //    StringBuilder sb = new StringBuilder();

    //    if (_dtCatalog != null && _dtCatalog.Rows.Count > 0)
    //    {
    //        DataRow[] rParent = _dtCatalog.Select(TblDanhMucSanPhamFields.DanhMucCha.Name + "= 0");
    //        sb.AppendFormat("<ul class='l1'>{0}</ul>", LoadCate(_dtCatalog, rParent));
    //        ltrCatalog.Text = sb.ToString();
    //    }
    //}
    ///// <summary>
    ///// dung de quy de lay cac danh muc cha con 
    ///// </summary>
    ///// <param name="_dt"></param>
    ///// <param name="rows"></param>
    ///// <returns></returns>
    //private string LoadCate(DataTable _dt,DataRow[] rows)
    //{
    //    StringBuilder sb = new StringBuilder();
    //    foreach (DataRow item in rows)
    //    {
    //        sb.Append("<li><a href='" + ResolveUrl(item[TblDanhMucSanPhamFields.Url.Name].ToString()) + "'>" + item[TblDanhMucSanPhamFields.TenDanhMuc.Name] + "</a>");
    //        DataRow[] rChild = _dt.Select(TblDanhMucSanPhamFields.DanhMucCha.Name + "= " + item[TblDanhMucSanPhamFields.Id.Name]);
    //        if (rChild.Length > 0)
    //        {
    //            sb.AppendFormat("<ul class='l2'>{0}</ul>", LoadCate(_dt, rChild));                
    //        }
    //        sb.Append("</li>");
    //    }
    //    return sb.ToString();
    //}

}